<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>iPhone 14 Pro Max - 商品详情</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f5f5;
        }

        /* 导航栏样式 */
        .main-nav {
            background: #ff3c3c;
            padding: 15px 0;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 15px;
        }

        .nav-content {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .logo {
            color: #fff;
            font-size: 24px;
            font-weight: bold;
            text-decoration: none;
        }

        /* 商品详情主体 */
        .product-container {
            background: white;
            margin: 20px auto;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 15px rgba(0,0,0,0.1);
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 40px;
        }

        /* 商品图片展示 */
        .product-gallery {
            position: relative;
        }

        .main-image {
            width: 100%;
            height: 400px;
            border-radius: 10px;
            overflow: hidden;
            margin-bottom: 20px;
        }

        .main-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .thumbnail-list {
            display: flex;
            gap: 10px;
        }

        .thumbnail {
            width: 80px;
            height: 80px;
            border-radius: 8px;
            overflow: hidden;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.3s ease;
        }

        .thumbnail.active {
            border-color: #ff3c3c;
        }

        .thumbnail img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* 商品信息 */
        .product-info {
            padding: 20px 0;
        }

        .product-title {
            font-size: 24px;
            margin-bottom: 15px;
            color: #333;
        }

        .product-price {
            font-size: 28px;
            color: #ff3c3c;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .original-price {
            color: #999;
            text-decoration: line-through;
            font-size: 16px;
            margin-left: 10px;
        }

        .product-rating {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
        }

        .rating-stars {
            color: #ffd700;
        }

        .rating-count {
            color: #666;
        }

        /* 规格选择 */
        .specs-section {
            margin-bottom: 20px;
        }

        .specs-title {
            font-size: 16px;
            color: #666;
            margin-bottom: 10px;
        }

        .specs-options {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .spec-option {
            padding: 8px 20px;
            border: 2px solid #eee;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .spec-option.selected {
            border-color: #ff3c3c;
            color: #ff3c3c;
            background: #fff5f5;
        }

        /* 购买按钮 */
        .purchase-actions {
            display: flex;
            gap: 20px;
            margin-top: 30px;
        }

        .action-btn {
            flex: 1;
            padding: 15px 0;
            border-radius: 25px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
        }

        .buy-now {
            background: #ff3c3c;
            color: white;
        }

        .add-to-cart {
            background: #fff5f5;
            color: #ff3c3c;
            border: 2px solid #ff3c3c;
        }

        .action-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255,60,60,0.2);
        }

        /* 商品详细信息 */
        .product-details {
            grid-column: 1 / -1;
            border-top: 1px solid #eee;
            padding-top: 30px;
        }

        .details-tabs {
            display: flex;
            gap: 30px;
            margin-bottom: 20px;
        }

        .tab {
            padding: 10px 0;
            cursor: pointer;
            color: #666;
            position: relative;
        }

        .tab.active {
            color: #ff3c3c;
        }

        .tab.active::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 100%;
            height: 2px;
            background: #ff3c3c;
        }

        .detail-content {
            color: #666;
            line-height: 1.8;
        }

        .detail-content img {
            max-width: 100%;
            margin: 20px 0;
        }

        /* 商品参数 */
        .params-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        .params-table td {
            padding: 12px;
            border: 1px solid #eee;
        }

        .params-table tr td:first-child {
            background: #f9f9f9;
            width: 120px;
            color: #666;
        }

        /* 评论区样式 */
        .reviews-container {
            margin-top: 20px;
        }

        .review-item {
            border-bottom: 1px solid #eee;
            padding: 20px 0;
        }

        .review-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .reviewer-info {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .reviewer-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            overflow: hidden;
        }

        .reviewer-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .reviewer-name {
            font-weight: bold;
            color: #333;
        }

        .review-date {
            color: #999;
            font-size: 14px;
        }

        .review-rating {
            color: #ffd700;
            margin-bottom: 10px;
        }

        .review-content {
            color: #333;
            line-height: 1.6;
            margin-bottom: 10px;
        }

        .review-images {
            display: flex;
            gap: 10px;
            margin-top: 10px;
        }

        .review-image {
            width: 80px;
            height: 80px;
            border-radius: 8px;
            overflow: hidden;
            cursor: pointer;
        }

        .review-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* 评论表单样式 */
        .review-form {
            margin-top: 30px;
            background: #f9f9f9;
            padding: 20px;
            border-radius: 8px;
        }

        .form-title {
            font-size: 18px;
            margin-bottom: 15px;
            color: #333;
        }

        .rating-input {
            margin-bottom: 15px;
        }

        .rating-input i {
            cursor: pointer;
            color: #ddd;
            font-size: 20px;
        }

        .rating-input i.active {
            color: #ffd700;
        }

        .review-textarea {
            width: 100%;
            height: 100px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-bottom: 15px;
            resize: vertical;
        }

        .review-submit {
            background: #ff3c3c;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .review-submit:hover {
            background: #ff5555;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="main-nav">
        <div class="container">
            <div class="nav-content">
                <a href="淘乐乐商城.html" class="logo">淘乐乐</a>
                <div class="user-links">
                    <a href="购物车.html" style="color: white; text-decoration: none; margin-right: 20px;">
                        <i class="fas fa-shopping-cart"></i> 购物车
                    </a>
                    <a href="个人中心.html" style="color: white; text-decoration: none;">
                        <i class="fas fa-user"></i> 个人中心
                    </a>
                </div>
            </div>
        </div>
    </nav>

    <!-- 商品详情主体 -->
    <div class="container">
        <div class="product-container">
            <!-- 商品图片展示 -->
            <div class="product-gallery">
                <div class="main-image">
                    <img src="images/5.jpg" alt="iPhone 14 Pro Max" id="mainImage">
                </div>
                <div class="thumbnail-list">
                    <div class="thumbnail active" onclick="changeImage('images/5.jpg', this)">
                        <img src="images/5.jpg" alt="正面">
                    </div>
                    <div class="thumbnail" onclick="changeImage('images/5-2.jpg', this)">
                        <img src="images/5-2.jpg" alt="背面">
                    </div>
                    <div class="thumbnail" onclick="changeImage('images/5-3.jpg', this)">
                        <img src="images/5-3.jpg" alt="侧面">
                    </div>
                </div>
            </div>

            <!-- 商品信息 -->
            <div class="product-info">
                <h1 class="product-title">iPhone 14 Pro Max</h1>
                <div class="product-price">
                    ¥8999 <span class="original-price">¥9999</span>
                </div>
                <div class="product-rating">
                    <div class="rating-stars">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star-half-alt"></i>
                    </div>
                    <span class="rating-count">(2.5k 评价)</span>
                </div>

                <!-- 规格选择 -->
                <div class="specs-section">
                    <div class="specs-title">颜色</div>
                    <div class="specs-options">
                        <div class="spec-option selected">深空黑色</div>
                        <div class="spec-option">银色</div>
                        <div class="spec-option">金色</div>
                        <div class="spec-option">暗紫色</div>
                    </div>
                </div>

                <div class="specs-section">
                    <div class="specs-title">存储容量</div>
                    <div class="specs-options">
                        <div class="spec-option">128GB</div>
                        <div class="spec-option selected">256GB</div>
                        <div class="spec-option">512GB</div>
                        <div class="spec-option">1TB</div>
                    </div>
                </div>

                <!-- 购买按钮 -->
                <div class="purchase-actions">
                    <button class="action-btn add-to-cart" onclick="addToCart()">加入购物车</button>
                    <button class="action-btn buy-now" onclick="location.href='付款界面.html'">立即购买</button>
                </div>
            </div>

            <!-- 商品详细信息 -->
            <div class="product-details">
                <div class="details-tabs">
                    <div class="tab active" onclick="switchTab(this, 'description')">商品介绍</div>
                    <div class="tab" onclick="switchTab(this, 'params')">规格参数</div>
                    <div class="tab" onclick="switchTab(this, 'reviews')">用户评价</div>
                </div>

                <div class="detail-content" id="description">
                    <h3>产品特点</h3>
                    <p>iPhone 14 Pro Max 采用创新的灵动岛设计，搭载 A16 仿生芯片，配备 4800 万像素主摄，支持电影效果模式和运动模式等创新功能。</p>
                    <img src="images/5-detail.jpg" alt="产品细节">
                    <p>全新的永远显示功能让你无需唤醒屏幕即可查看重要信息，而超瓷晶面板则带来出色的防护性能。</p>
                </div>

                <div class="detail-content" id="params" style="display: none;">
                    <table class="params-table">
                        <tr>
                            <td>处理器</td>
                            <td>A16 仿生芯片</td>
                        </tr>
                        <tr>
                            <td>屏幕</td>
                            <td>6.7 英寸 Super Retina XDR 显示屏</td>
                        </tr>
                        <tr>
                            <td>摄像头</td>
                            <td>4800万像素主摄 + 1200万像素超广角 + 1200万像素长焦</td>
                        </tr>
                        <tr>
                            <td>电池</td>
                            <td>支持快充，最长可达29小时视频播放</td>
                        </tr>
                    </table>
                </div>

                <div class="detail-content" id="reviews" style="display: none;">
                    <h3>用户评价</h3>
                    <div class="reviews-container">
                        <!-- 评论列表 -->
                        <div class="review-item">
                            <div class="review-header">
                                <div class="reviewer-info">
                                    <div class="reviewer-avatar">
                                        <img src="https://via.placeholder.com/40" alt="用户头像">
                                    </div>
                                    <div>
                                        <div class="reviewer-name">张三</div>
                                        <div class="review-date">2024-03-15</div>
                                    </div>
                                </div>
                                <div class="review-rating">
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                </div>
                            </div>
                            <div class="review-content">
                                手机非常好用，外观设计很漂亮，性能也很强大。拍照效果特别棒，夜景模式表现优秀。电池续航也很满意，一天重度使用没问题。
                            </div>
                            <div class="review-images">
                                <div class="review-image">
                                    <img src="images/review1.jpg" alt="评价图片">
                                </div>
                                <div class="review-image">
                                    <img src="images/review2.jpg" alt="评价图片">
                                </div>
                            </div>
                        </div>

                        <div class="review-item">
                            <div class="review-header">
                                <div class="reviewer-info">
                                    <div class="reviewer-avatar">
                                        <img src="https://via.placeholder.com/40" alt="用户头像">
                                    </div>
                                    <div>
                                        <div class="reviewer-name">李四</div>
                                        <div class="review-date">2024-03-14</div>
                                    </div>
                                </div>
                                <div class="review-rating">
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="fas fa-star"></i>
                                    <i class="far fa-star"></i>
                                </div>
                            </div>
                            <div class="review-content">
                                整体很满意，就是价格稍贵。不过配置和做工都对得起这个价位，尤其是相机系统，可以说是目前最好的手机相机了。
                            </div>
                        </div>

                        <!-- 评论表单 -->
                        <div class="review-form">
                            <h4 class="form-title">发表评价</h4>
                            <div class="rating-input">
                                <i class="far fa-star" data-rating="1" onclick="setRating(1)"></i>
                                <i class="far fa-star" data-rating="2" onclick="setRating(2)"></i>
                                <i class="far fa-star" data-rating="3" onclick="setRating(3)"></i>
                                <i class="far fa-star" data-rating="4" onclick="setRating(4)"></i>
                                <i class="far fa-star" data-rating="5" onclick="setRating(5)"></i>
                            </div>
                            <textarea class="review-textarea" placeholder="分享你的使用体验..."></textarea>
                            <button class="review-submit" onclick="submitReview()">发表评价</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 切换商品图片
        function changeImage(src, element) {
            document.getElementById('mainImage').src = src;
            document.querySelectorAll('.thumbnail').forEach(thumb => {
                thumb.classList.remove('active');
            });
            element.classList.add('active');
        }

        // 切换规格选项
        document.querySelectorAll('.spec-option').forEach(option => {
            option.addEventListener('click', function() {
                const parent = this.parentElement;
                parent.querySelectorAll('.spec-option').forEach(opt => {
                    opt.classList.remove('selected');
                });
                this.classList.add('selected');
            });
        });

        // 切换详情标签
        function switchTab(element, contentId) {
            // 切换标签样式
            document.querySelectorAll('.tab').forEach(tab => {
                tab.classList.remove('active');
            });
            element.classList.add('active');

            // 切换内容显示
            document.querySelectorAll('.detail-content').forEach(content => {
                content.style.display = 'none';
            });
            document.getElementById(contentId).style.display = 'block';
        }

        // 添加到购物车
        function addToCart() {
            const color = document.querySelector('.specs-options .selected').textContent;
            const storage = document.querySelector('.specs-options:last-child .selected').textContent;
            const specs = `${color} ${storage}`;
            
            const product = {
                name: 'iPhone 14 Pro Max',
                price: 8999,
                image: 'images/5.jpg',
                specs: specs,
                quantity: 1
            };

            let cartItems = JSON.parse(localStorage.getItem('cartItems')) || [];
            cartItems.push(product);
            localStorage.setItem('cartItems', JSON.stringify(cartItems));
            
            alert('添加成功！');
        }

        // 设置评分
        function setRating(rating) {
            const stars = document.querySelectorAll('.rating-input i');
            stars.forEach((star, index) => {
                if (index < rating) {
                    star.className = 'fas fa-star active';
                } else {
                    star.className = 'far fa-star';
                }
            });
        }

        // 提交评论
        function submitReview() {
            const rating = document.querySelectorAll('.rating-input i.active').length;
            const content = document.querySelector('.review-textarea').value;

            if (rating === 0) {
                alert('请选择评分');
                return;
            }

            if (!content.trim()) {
                alert('请输入评价内容');
                return;
            }

            // 创建新评论
            const reviewsContainer = document.querySelector('.reviews-container');
            const newReview = document.createElement('div');
            newReview.className = 'review-item';
            newReview.innerHTML = `
                <div class="review-header">
                    <div class="reviewer-info">
                        <div class="reviewer-avatar">
                            <img src="https://via.placeholder.com/40" alt="用户头像">
                        </div>
                        <div>
                            <div class="reviewer-name">我</div>
                            <div class="review-date">${new Date().toLocaleDateString()}</div>
                        </div>
                    </div>
                    <div class="review-rating">
                        ${Array(rating).fill('<i class="fas fa-star"></i>').join('')}
                        ${Array(5-rating).fill('<i class="far fa-star"></i>').join('')}
                    </div>
                </div>
                <div class="review-content">${content}</div>
            `;

            // 将新评论插入到评论列表的开头
            reviewsContainer.insertBefore(newReview, reviewsContainer.firstChild);

            // 清空表单
            document.querySelector('.review-textarea').value = '';
            setRating(0);

            alert('评价发表成功！');
        }
    </script>
</body>
</html> 